<?php
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
// DLMan by Shedd Technologies International		  				//
// http://www.dlman.com | info@dlman.com							//
// Copyright 2003 by STI, All rights reserved.						//
// ---------------------------------------------------------------- //
// Usage of this software is governed by the terms of GPL. 	    	//
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//

require("cvar.php");
//Stage 5A: Complete Database Additions for Administrator
if($stage=="5A"){
	//register admin
	
	//load database connection information
	require($file);
	//mysql connection should have been created
	
	//validate input
	if(!isset($username)||!isset($password)){
		die("You must set a username & password!");
	}
	if(!isset($email)){
		die("You must include an email address!");
	}
	if($password!=$password2){
		die("Entered Password DO NOT match!");
	}
	if($config->password=="md5"){
		$password2=md5($password2);
	}
	$result=mysql_query("SELECT * FROM ".$mysql['fpre'].'user'." WHERE ".$config->field['username']."='$username';");
	$rows=mysql_numrows($result);
	if($rows!=0){
		die("Username is in use!");
	}
	
	//generate SQL
	$result="";
	if(!$result=mysql_query("INSERT INTO ".$config->dt['user']." (`".$config->field['userid']."`, `".$config->field['username']."`, `".$config->field['password']."`, `".$config->field['email']."`,`".$config->field['usergroupid']."`,`".$config->field['joindate']."`,`".$config->field['lastactivity']."`) VALUES ('', '".htmlspecialchars($username)."', '".$password2."', '".strip_tags($email)."','".$config->values['admin']."','".time()."','".time()."');")){
		print "<p>Error in updating data!<br>";
		print mysql_error();
		print '<br><a href="'.$PHP_SELF;
		print '?stage=5A">Click Here to try again</a><br><br>';
		print "$sql</p>";
		$err=true;
	}//end error

	if($err!=true){
		?><br><br><div align="center">
		<STRONG><FONT face=Verdana size=2>You have been registered.</FONT></STRONG>
		<?php
		print '<br><br><a href="setup_8.php?';
		print 'stage=6">Click Here to Continue</a></div><br><br>';
	}//end no error
	else{
		print "Error in updating information.  Please try again.";
	}
}//end stage 5A
?>
